interface KV {
  text: string;
  value: any
};

interface SessionInterface {


  type: () => number;
  id: () => number;
  name: () => string;
  icon: () => string;
  time: () => number;
  seq: () => number;
  unread: () => number;
  isFinished: () => boolean;

}

class Session implements SessionInterface {
  type: any;
  id: any;
  name: any;
  icon: any;
  time: any;
  seq: any;
  unread: any;
  isFinished: any;

  constructor(type, id, name, icon, time, seq, unread, isFinished) {
    this.type = type;
    this.id = id;
    this.name = name;
    this.icon = icon;
    this.time = time;
    this.seq = seq;
    this.unread = unread;
    this.isFinished = isFinished;
  }
}

interface Text {
  text: string;
  getText: () => string;
  toHtml: () => string;
}

interface Face {
  index: number;
  data: any;
  getIndex: () => number;
  getData: () => any;
  toHtml: () => string;
}

interface Location {
  index: number;
  data: any;
  getIndex: () => number;
  getData: () => any;
  toHtml: () => string;
}


interface Images {
  imageId: number;
  format: string;

  Image: Image;

  addImage: (image) => void;
  toHtml: () => string;
  togetImageIdHtml: () => number;
  getImageFormat: () => string;
  getImage: (type: number) => any;
  getImageId: () => any;
}

interface Image {
  type: number;
  size: number;
  width: number;
  height: number;
  url: string;

  getType: () => number;
  getSize: () => number;
  getWidth: () => number;
  getHeight: () => number;
  getUrl: () => string;

}

interface Sound {
  uuid: string; // 文件id
  second: number;
  size: number;
  senderId: number;
  receiverId: number;
  downFlag: number;
  busiId: number;

  getUUID: () => number;
  getSecond: () => number;
  getSize: () => number;
  getSenderId: () => number;
  getDownUrl: () => string;
  toHtml: () => string;
}

interface File {
  uuid: string; // 文件id
  second: number;
  size: number;
  senderId: number;
  receiverId: number;
  downFlag: number;
  busiId: number;
  getUUID: () => number;
  getSecond: () => number;
  getSize: () => number;
  getSenderId: () => number;
  getDownFlag: () => number;
  getDownUrl: () => string;
  toHtml: () => string;
}

interface GroupTip {
  opType: number; //操作类型
  opUserId: number; //操作者id
  groupId: number;
  groupName: string;
  userIdList: Array<number>;  //被操作的用户id列表
  groupInfoList: Array<number>; //新的群资料信息，群资料变更时才有值
  memberInfoList: Array<number>; //新的群成员资料信息，群成员资料变更时才有值
  groupMemberNum: any; //群成员数，操作类型为加群或者退群时才有值
  userinfo: Array<any>; //被操作的用户信息列表列表

  GroupInfo: GroupInfo;
  MemberInfo: MemberInfo;

  addGroupInfo: (groupInfo: GroupInfo) => void;
  addMemberInfo: (memberInfo: MemberInfo) => void;
  getOpType: () => number;
  getOpUserId: () => number;
  getGroupId: () => number;
  getGroupName: () => string;
  getUserIdList: () => Array<number>;
  getUserInfo: () => Array<any>;
  getGroupInfoList: () => Array<GroupInfo>;
  getMemberInfoList: () => Array<MemberInfo>;
  getGroupMemberNum: () => number;
  setGroupMemberNum: (groupMemberNum: number) => void;
  toHtml: () => string;
}

// class Msg.Elem.GroupTip.GroupInfo，变更的群资料信息对象
interface GroupInfo {
  type: number;
  value: any;

  getType: () => number;
  getValue: () => any;
}

// class Msg.Elem.GroupTip.MemberInfo，变更的群成员资料信息对象
interface MemberInfo {
  userId: number; //群成员id
  shutupTime: any; //群成员被禁言时间，0表示取消禁言，大于0表示被禁言时长，单位：秒

  getUserId: () => number;
  getShutupTime: () => number;
}

interface Custom {
  data: any;
  desc: any;
  ext: any;
  getData: () => any;
  getDesc: () => any;
  getExt: () => any;

}



interface Elem {
  type: number;
  content: string;

  Text: Text;
  Face: Face;
  Location: Location;
  Images: Images;
  Sound: Sound;
  File: File;
  GroupTip: GroupTip;
  Custom: Custom;

  getType: () => number;
  getContent: () => string;
  toHtml: () => string;
}


interface Msg {
  elems: Array<Elem>;
  sess: Session;
  isSend: boolean;
  seq: number;
  random: number;
  time: number;
  fromAccount: string;
  subType: number;
  fromAccountNick: string;
  fromAccountHeadurl: string;

  Elem: Elem;
  extraInfo: any;

  getSession: () => Session;
  getType: () => number;
  getSubType: () => number;
  getFromAccount: () => string;
  getFromAccountNick: () => string;
  getIsSend: () => boolean;
  getSeq: () => number;
  getTime: () => number;
  getRandom: () => number;
  getElems: () => Array<any>;
  getMsgUniqueId: () => string;
  addText: (text: string) => void;
  addFace: (face: string) => void;
  addImage: (image: string) => void;
  addLocation: (location: string) => void;
  addFile: (file: string) => void;
  addCustom: (custom: string) => void;
  addElem: (elem: string) => void;
  toHtml: () => string;

}


interface MsgStore {
  sessMap: () => any; //跟所有用户或群的聊天记录MAP
  sessCount: () => number;
  sessByTypeId: (type: number, id: number) => Session;
  delSessByTypeId: (type: number, id: any) => boolean;
  resetCookieAndSyncFlag: () => void;
}

interface Webim {
  Session: any;
  // Session: Session;
  Msg: any;
  Text: any;
  Face: any;
  Location: any;
  Images: any;
  Image: any;
  Sound: any;
  File: any;
  GroupTip: any;
  GroupInfo: any;
  MemberInfo: any;
  Custom: any;
  Elem: Elem;
  MsgStore: MsgStore;
  login: (loginInfo, listeners, options, cbOk, cbErr) => void,
  syncMsgs: (cbOk, cbErr) => void,


  getC2CHistoryMsgs: (options, cbOk, cbErr) => void,


  syncGroupMsgs: (options, cbOk, cbErr) => void,


  sendMsg: (msg, cbOk, cbErr) => void,


  logout: (cbOk, cbErr) => void,


  setAutoRead: (selSess, isOn, isResetAll) => void,

  getProfilePortrait: (options, cbOk, cbErr) => void,


  setProfilePortrait: (options, cbOk, cbErr) => void,

  applyAddFriend: (options, cbOk, cbErr) => void,

  getPendency: (options, cbOk, cbErr) => void,


  deletePendency: (options, cbOk, cbErr) => void,


  responseFriend: (options, cbOk, cbErr) => void,


  getAllFriend: (options, cbOk, cbErr) => void,

  deleteFriend: (options, cbOk, cbErr) => void,


  addBlackList: (options, cbOk, cbErr) => void,

  getBlackList: (options, cbOk, cbErr) => void,

  deleteBlackList: (options, cbOk, cbErr) => void,

  uploadPic: (options, cbOk, cbErr) => void,


  createGroup: (options, cbOk, cbErr) => void,


  applyJoinGroup: (options, cbOk, cbErr) => void,

  /*  handleApplyJoinGroup
   *   处理申请加群(同意或拒绝)
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  handleApplyJoinGroup: (options, cbOk, cbErr) => void,

  /*  deleteApplyJoinGroupPendency
   *   删除加群申请
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  deleteApplyJoinGroupPendency: (options, cbOk, cbErr) => void,


  /*  quitGroup
   *  主动退群
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  quitGroup: (options, cbOk, cbErr) => void,

  /*  getGroupPublicInfo
   *   读取群公开资料-高级接口
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  getGroupPublicInfo: (options, cbOk, cbErr) => void,

  /*  getGroupInfo
   *   读取群详细资料-高级接口
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  getGroupInfo: (options, cbOk, cbErr) => void,

  /*  modifyGroupBaseInfo
   *   修改群基本资料
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  modifyGroupBaseInfo: (options, cbOk, cbErr) => void,

  /*  destroyGroup
   *  解散群
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  destroyGroup: (options, cbOk, cbErr) => void,

  /*  getJoinedGroupListHigh
   *   获取我的群组-高级接口
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  getJoinedGroupListHigh: (options, cbOk, cbErr) => void,

  getGroupMemberInfo: (options, cbOk, cbErr) => void,

  addGroupMember: (options, cbOk, cbErr) => void,


  modifyGroupMember: (options, cbOk, cbErr) => void,
  forbidSendMsg: (options, cbOk, cbErr) => void,


  deleteGroupMember: (options, cbOk, cbErr) => void,

  /*  getPendencyGroup
   *   获取群组未决列表
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  getPendencyGroup: (options, cbOk, cbErr) => void,

  /*  getPendencyReport
   *   好友未决已读上报
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  getPendencyReport: (options, cbOk, cbErr) => void,

  /*  getPendencyGroupRead
   *   群组未决已读上报
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  getPendencyGroupRead: (options, cbOk, cbErr) => void,

  /*  sendCustomGroupNotify
   *   发送自定义群通知
   * params:
   *   options    - 请求参数，详见api文档
   *   cbOk   - ()类型, 成功时回调函数
   *   cbErr  - (err)类型, 失败时回调函数, err为错误对象
   * return:
   *   (无)
   */
  sendCustomGroupNotify: (options, cbOk, cbErr) => void,

  /* class webim.Msg
   *   一条消息的描述类, 消息发送、接收的API中都会涉及此类型的对象
   * properties:
   *   sess   - Session object-ref, 消息所属的会话(e.g:我与好友A的C2C会话，我与群组G的GROUP会话)
   *   isSend - Boolean, true表示是我发出消息, false表示是发给我的消息)
   *   seq    - Integer, 消息序列号, 用于判断消息是否同一条
   *   random - Integer, 消息随机数,用于判断消息是否同一条
   *   time   - Integer, 消息时间戳, 为unix timestamp
   *   fromAccount -String,  消息发送者帐号
   *   subType -Integer,  消息子类型，c2c消息时，0-表示普通消息；群消息时，0-普通消息，1-点赞消息，2-提示消息
   *   fromAccountNick -String,  消息发送者昵称
   *   elems  - Array of webim.Msg.Elem, 描述消息内容的元素列表
   * constructor:
   *   Msg(sess, isSend, seq,random time,fromAccount) - 构造函数, 参数定义同上面properties中定义
   * methods:
   *   addText(text)  - 向elems中添加一个TEXT元素
   *   addFace(face)  - 向elems中添加一个FACE元素
   *   toHtml()       - 转成可展示的html String
   *addFace
   * sub-class webim.Msg.Elem
   *   消息中一个组成元素的描述类, 一条消息的内容被抽象描述为N个元素的有序列表
   * properties:
   *   type   - 元素类型, 目前有TEXT(文本)、FACE(表情)、IMAGE(图片)等
   *   content- 元素内容体, 当TEXT时为String, 当PIC时为UrlString
   * constructor:
   *   Elem(type, content) - 构造函数, 参数定义同上面properties中定义
   *
   * sub-class webim.Msg.Elem.TextElem
   *   文本
   * properties:
   *   text  - String 内容
   * constructor:
   *   TextElem(text) - 构造函数, 参数定义同上面properties中定义
   *
   * sub-class webim.Msg.Elem.FaceElem
   *   表情
   * properties:
   *   index  - Integer 表情索引, 用户自定义
   *   data   - String 额外数据，用户自定义
   * constructor:
   *   FaceElem(index,data) - 构造函数, 参数定义同上面properties中定义
   *
   *
   */
  Log: any,
  Tool: any,
  SESSION_TYPE: {
    GROUP: number,
    C2C: number,
  },
  MSG_MAX_LENGTH: any,
  C2C_MSG_SUB_TYPE: any,
  GROUP_MSG_SUB_TYPE: any,
  MSG_ELEMENT_TYPE:
  any,
  GROUP_TIP_TYPE:
  any,
  IMAGE_TYPE: any,
  GROUP_SYSTEM_TYPE:
  any,
  FRIEND_NOTICE_TYPE:
  any,
  GROUP_TIP_MODIFY_GROUP_INFO_TYPE:
  any,
  BROWSER_INFO: any,
  EmotionPicData: any,
  Emotions: any,
  EmotionPicDataIndex: any,
  EmotionDataIndexs: any,
  TLS_ERROR_CODE: any,
  CONNECTION_STATUS: any,
  UPLOAD_PIC_BUSSINESS_TYPE: any,
  RECENT_CONTACT_TYPE: any,
  UPLOAD_RES_TYPE: any,

}


export {
  KV,
  Session,
  Msg,
  Text,
  Face,
  Location,
  Images,
  Image,
  Sound,
  File,
  GroupTip,
  GroupInfo,
  MemberInfo,
  Custom,
  Elem,
  MsgStore,
  Webim,
};